<% layout('/layout/default.html', {title: '业务表详情', libs: ['validate','icheck']}){ %>
<div class="main-content">
    <div class="card-header">
        <i class="fa fa-sitemap"></i>基本信息
    </div>
    <form id="inputForm" action="${ctx}/gen/genTable/save" method="post" class="form-horizontal">
        <div class="card-body">
            <input type="hidden" name="id" value="${genTable.id}">
            <div class="row">
                <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <div class="form-group row">
                        <label class="col-form-label col-lg-4 col-md-4 text-right" title="表名">表名:</label>
                        <div class="col-lg-8 col-md-8 ">
                            <input type="text" name="name" value="${genTable.name}" class="form-control " readonly="readonly" maxlength="200" />
                        </div>
                    </div>
                </div>
                <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <div class="form-group row">
                        <label class="col-form-label col-lg-4 col-md-4 text-right" title="说明">说明:</label>
                        <div class="col-lg-8 col-md-8 ">
                            <input type="text" name="comments" value="${genTable.comments}" class="form-control required" maxlength="200" />
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <div class="form-group row">
                        <label class="col-form-label col-lg-4 col-md-4 text-right" title="类名">类名:</label>
                        <div class="col-lg-8 col-md-8">
                            <input type="text" name="className" value="${genTable.className}" class="form-control required" maxlength="200" />
                        </div>
                    </div>
                </div>
                <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <div class="form-group row">
                        <label class="col-form-label col-lg-4 col-md-4 text-right" title="父表表名">父表表名:</label>
                        <div class="col-lg-8 col-md-8">
                            <#form:select path="parentTable" name="nameAndComments" value="name" data="${tableList}" onValue="${genTable.parentTable}" class="form-control " />
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <div class="form-group row">
                        <label class="col-form-label col-lg-4 col-md-4 text-right" title="当前表外键">当前表外键:</label>
                        <div class="col-lg-8 col-md-8">
                            <#form:select path="parentTableFk" name="nameAndComments" value="name" data="${genTable.columnList}" onValue="${genTable.parentTableFk}"  class="form-control " />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row " style="margin-right: 0px;">
                <div class="box-header-in">
                    <div class="box-title">
                        <i class="fa fa-sitemap"></i>字段列表
                    </div>
                </div>
            </div>
            <div style="overflow-x:auto;">
                <table id="contentTable" class="table table-head-fixed table-bordered table-hover" cellspacing="0" width="100%">
                    <thead><tr><th title="数据库字段名">列名</th><th title="默认读取数据库字段备注">说明</th><th title="数据库中设置的字段类型及长度">物理类型</th><th title="实体对象的属性字段类型">Java类型</th>
                        <th title="实体对象的属性字段（对象名.属性名|属性名2|属性名3，例如：用户user.id|name|loginName，属性名2和属性名3为Join时关联查询的字段）">Java属性名称 <i class="icon-question-sign"></i></th>
                        <th title="是否是数据库主键">主键</th><th title="字段是否可为空值，不可为空字段自动进行空值验证">可空</th><th title="选中后该字段被加入到insert语句里">插入</th>
                        <th title="选中后该字段被加入到update语句里">编辑</th><th title="选中后该字段被加入到查询列表里">列表</th>
                        <th title="选中后该字段被加入到查询条件里">查询</th><th title="该字段为查询字段时的查询匹配放松">查询匹配方式</th>
                        <th title="字段在表单中显示的类型">显示表单类型</th><th title="显示表单类型设置为“下拉框、复选框、点选框”时，需设置字典的类型">字典类型</th><th>排序</th></tr></thead>
                    <tbody>
                    <% for(column in genTable.columnList) {
                    var index = columnLP.index-1;
                    %>
                    <tr${column.delFlag=='1'?' class="error" title="已删除的列，保存之后消失！"':''} >
                    <td nowrap="nowrap">
                        <input type="hidden" name="columnList[${index}].id" value="${column.id}"/>
                        <input type="hidden" name="columnList[${index}].delFlag" value="${column.delFlag}"/>
                        <input type="hidden" name="columnList[${index}].genTable.id" value="${column.genTable.id!}"/>
                        <input type="hidden" name="columnList[${index}].name" value="${column.name}"/>${column.name}
                    </td>
                    <td>
                        <input type="text" name="columnList[${index}].comments" value="${column.comments}" maxlength="200" class="form-control required" style="width:100px;"/>
                    </td>
                    <td nowrap="nowrap">
                        <input type="hidden" name="columnList[${index}].jdbcType" value="${column.jdbcType}"/>${column.jdbcType}
                    </td>
                    <td>
                        <select name="columnList[${index}].javaType" class="form-control required input-mini" style="width:85px;*width:75px">
                            <% for(dict in config.javaTypeList) { %>
                            <option value="${dict.value}" ${dict.value==column.javaType?'selected="selected"':''}" title="${dict.description}">${dict.label}</option>
                            <% } %>
                        </select>
                    </td>
                    <td>
                        <input type="text" name="columnList[${index}].javaField" value="${column.javaField}" maxlength="200" class="form-control required "/>
                    </td>
                    <td>
                        <input type="checkbox" name="columnList[${index}].isPk" value="1" ${column.isPk=='1' ? 'checked="checked"' : ''} class="form-control "/>
                    </td>
                    <td>
                        <input type="checkbox" name="columnList[${index}].isNull" value="1" ${column.isNull=='1' ? 'checked="checked"' : ''} class="form-control "/>
                    </td>
                    <td>
                        <input type="checkbox" name="columnList[${index}].isInsert" value="1" ${column.isInsert=='1' ? 'checked="checked"' : ''} class="form-control "/>
                    </td>
                    <td>
                        <input type="checkbox" name="columnList[${index}].isEdit" value="1" ${column.isEdit=='1' ? 'checked="checked"' : ''} class="form-control "/>
                    </td>
                    <td>
                        <input type="checkbox" name="columnList[${index}].isList" value="1" ${column.isList=='1' ? 'checked="checked"' : ''} class="form-control "/>
                    </td>
                    <td>
                        <input type="checkbox" name="columnList[${index}].isQuery" value="1" ${column.isQuery=='1' ? 'checked="checked"' : ''} class="form-control "/>
                    </td>
                    <td>
                        <select name="columnList[${index}].queryType" class="form-control required input-mini">
                            <% for(dict in config.queryTypeList) {
                            var dictVal = @Encodes.escapeHtml(dict.value);
                            var dictLab = @Encodes.escapeHtml(dict.label);
                            %>
                            <option value="${dictVal}" ${dictVal==column.queryType?'selected="selected"':''} title="${dict.description}">${dictLab}</option>
                            <% } %>
                        </select>
                    </td>
                    <td>
                        <select name="columnList[${index}].showType" class="form-control required" style="width:100px;">
                            <% for(dict in config.showTypeList) { %>
                            <option value="${dict.value}" ${dict.value==column.showType?'selected="selected"':''} title="${dict.description}">${dict.label}</option>
                            <% } %>
                        </select>
                    </td>
                    <td>
                        <input type="text" name="columnList[${index}].dictType" value="${column.dictType}" maxlength="200" class="form-control "/>
                    </td>
                    <td>
                        <input type="text" name="columnList[${index}].sort" value="${column.sort}" maxlength="200" class="form-control required digits"/>
                    </td>
                    </tr>
                    <% } %>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="box-footer">
            <div class="row">
                <div class="offset-md-2 col-md-10">
                    <% if (hasPermi('sys:dict:edit')){ %>
                    <button type="submit" class="btn btn-primary btn-sm" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>
                    <% } %>
                    <button type="button" class="btn btn-secondary btn-sm" id="btnCancel" onclick="window.parent.closeCurrentTabPage();"><i class="fa fa-reply-all"></i> 关 闭</button>
                </div>
            </div>
        </div>

    </form>
</div>
<% } %>

<script type="text/javascript">
    $("#inputForm").validate({
        submitHandler: function(form){
            $("input[type=checkbox]").each(function(){
                $(this).after("<input type=\"hidden\" name=\""+$(this).attr("name")+"\" value=\""
                    +($(this).is(':checked')?"1":"0")+"\"/>");
                $(this).attr("name", "_"+$(this).attr("name"));
            });

            js.ajaxSubmitForm($(form), function(data){
                js.showMessage(data.message);

                if(data.result == 'true'){
                    window.parent.closeCurrentTabPage(window.parent.refreshTab);
                }
            });
        }
    });

</script>
